package com.huaxin.hxcloud.work;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.huaxin.common.Entity.ScStationDTO;
import com.huaxin.hxcloud.R;

/**
 * @author songxf
 * @date 2017/12/13
 * @Desc 重构站点Adapter
 * Copyright HUAXIN DATA. All rights reserved.
 */
public class HxScStationInfoAdapter extends BaseQuickAdapter<ScStationDTO.DataBean.DeviceListBean, BaseViewHolder> {
    private Context mContext;
    private String  flagState;

    public HxScStationInfoAdapter(Context context) {
        super(R.layout.item_scdevice);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, final ScStationDTO.DataBean.DeviceListBean item) {
        //设备图片
        //ImageView deviceImg = helper.getView(R.id.device_img);
        //设备名称
        TextView deviceNameTv = helper.getView(R.id.device_name_tv);
        deviceNameTv.setText(item.getDeviceName());
        //型号型号
        //设备状态
        TextView deviceStateTv = helper.getView(R.id.device_state_tv);
        deviceStateTv.setText(("型号：" + item.getModel()));
        //品牌
        //采集周期
        TextView deviceReadTv = helper.getView(R.id.device_read_tv);
        deviceReadTv.setText(("品牌：" + item.getBrand()));
        helper.getView(R.id.device_svg_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                HxScRepairRecordActivity.start(mContext, item.getDeviceCode());
            }
        });
      /*  //SN号
        TextView deviceSnTv = helper.getView(R.id.divece_sn_tv);
        //传输周期
        TextView deviceSendTv = helper.getView(R.id.device_send_tv);
        //添加点击事件 指标
        helper.addOnClickListener(R.id.device_realdata_tv);
        //工艺图
        helper.addOnClickListener(R.id.device_svg_tv);
        helper.addOnClickListener(R.id.item_view);
       Glide.with(mContext).load(item.getImgUrl()).apply(new RequestOptions().error(Constants
                .DEFAULT_LOADING_IMG)).into(deviceImg);*/
      /*  switch (item.getState()) {
            case 0:
                flagState = "正常";
                break;
            case 1:
                flagState = "超时";
                break;
            case 2:
                flagState = "故障";
                break;
            case 3:
                flagState = "未初始化";
                break;
            default:
                break;
        }

        deviceStateTv.setText(("状态：" + flagState));
        if (Util.checkNull(item.getReadCycle())) {
            deviceReadTv.setText("采集周期：" + "暂无");
        } else {
            deviceReadTv.setText(("采集周期：" + item.getReadCycle()));
        }
        if (Util.checkNull(item.getSnCode())) {
            deviceSnTv.setText("SN号：" + "暂无");
        } else {
            deviceSnTv.setText(("SN号：" + item.getSnCode()));
        }

        if (Util.checkNull(item.getSendCycle())) {
            deviceSendTv.setText("传输周期：" + "暂无");
        } else {
            deviceSendTv.setText(("传输周期：" + item.getSendCycle()));
        }*/

    }
}
